<?php include_once '../../../include/inc_session.php';

	if(isset($_GET['Identifiant_personne']) && !empty($_GET['Identifiant_personne']))
	{ // Vérifier si Identifiant_personne est passé en paramètre
		$idPersonne = $_GET['Identifiant_personne'];
	}
	
	$idContrat = $_SESSION['idcontrat'];
	
	$oCoordComm = new dataObject_coordCommunication($_GET["Identifiant_communication"]);
	
	$TYPE_COMM   =  (isset($_POST['Type_coordonnees_communication']))  ?  $_POST['Type_coordonnees_communication']  : $oCoordComm->_TYPE_COORD_COMM;
	$VAL_COMM    =  (isset($_POST['OCM_Valeur_coordonnee_communication'])) ?  $_POST['OCM_Valeur_coordonnee_communication'] : $oCoordComm->_VALEUR_COORD_COMM;

	if ($gbFormValid) 
	{
		$oCoordComm->_TYPE_COORD_COMM 	    = $TYPE_COMM;
		$oCoordComm->_ETAT_COORD_COMM 	    = $_POST['Etat_coordonnees_communication'];
		$oCoordComm->_VALEUR_COORD_COMM 	= $VAL_COMM;
		$oCoordComm->_IDENTIFIANT_PERSONNE	= $_POST['Identifiant_personne'];
		
		$id = $oCoordComm->coordCommunication_update();
		
		if($id===false) $oForm->ajouterErreur(chgmt_couv_mod_comm_pbm);
		else $oForm->ajouterErreur(communication_modif);
		//header("location:index.php?Identifiant_personne=".$idPersonne);
	}

	// Suppression de la communication (rendre l'état de la communication à Inactif : I)
	if(isset($_GET["supp"]) && $_GET["supp"]=="1" && isset($_GET["Identifiant_communication"]) && isset($_GET["Identifiant_communication"]))
	{
		$iResult = $oCoordComm->coordCommunication_desactive();
		if($iResult)
		{
			$deleteGoTo = "index.php?Identifiant_communication=". $_GET['Identifiant_communication'] ."&Identifiant_personne=". $_GET['Identifiant_personne']."&msg=supp";
		}
		else
		{
			$deleteGoTo = "index.php?Identifiant_communication=". $_GET['Identifiant_communication'] ."&Identifiant_personne=". $_GET['Identifiant_personne'] ."&msg=pbm";
		}
		header(sprintf("Location: %s", $deleteGoTo));
	
	}
	
	$nom_module_saisie="Détail communication";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=8" />
			<title>Modification coordonneés de communication</title>
			<link rel="stylesheet" type="text/css" href="../../../css/main.css" />
            <link rel="stylesheet" type="text/css" href="list.css" />
			<!--[if IE 7]>
            	<link rel="stylesheet" type="text/css" href="../../css/ie7.css" />
            	<link rel="stylesheet" type="text/css" href="form_ie7.css" />
            <![endif]-->
	</head>
<body>
<div id="sf_menu1">
	<h3><?php echo $oBloc->_MENU_NOM ?></h3>
	<div id="information_erreur" class="false">
        <ul id="message">
        	<li><?php $aMsg =$oForm->getValidMessage(); echo (!empty($aMsg))? $aMsg[0]['message'] : ''; ?></li>
        </ul>
    </div>
</div>


<div class="corps1">
<div class="cleared"></div>
<div id="br"></div>
<!--/***************************************/-->

<form action="<?php echo $sEditFormAction; ?>" method="post" name="form1" id="form1">
	<div class="imgleft"></div>
	<div class="imgmiddle">
    <div class="btn">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $oFonction->_MENU_AFFICHE; ?></h5>
        </span><span class="btnright"></span>
    </div>
  	<div class="btn1">
    	<span class="btnleft"></span>
        <span class="btnmiddle">
        	<h5><?php echo $nom_module_saisie; ?></h5>
        </span>
        <span class="btnright"></span>
    </div>
	<div class="formulaire">
  <table class="tabform">
    <tr>
      <td class="td0">TYPE COORDONNEE</td>
      <td><select name="Type_coordonnees_communication">
	<?php 
	$aListType = dataObject_elementdico::elementdico_getListFromCode(dataObject_dictionnaire::TYPE_COORD_COMMUNICATION);
	foreach ($aListType as $i => $aRow)
	{ ?>
		<option value="<?php echo $aRow['Code_element']; ?>" <?php if(isset($_POST['Type_coordonnees_communication'])){if (!(strcmp($aRow['Code_element'], htmlentities($_POST['Type_coordonnees_communication'], ENT_COMPAT, 'utf-8')))) {echo "SELECTED";}}else{ if (!(strcmp($aRow['Code_element'], htmlentities($oCoordComm->_TYPE_COORD_COMM, ENT_COMPAT, 'utf-8')))) {echo "SELECTED";}} ?> ><?php echo $aRow['Nom_element']; ?></option>
	<?php 
	} ?>
      </select>
      </td>
    </tr>
	<input type="hidden" name="Etat_coordonnees_communication" value="<?php echo htmlentities($oCoordComm->_ETAT_COORD_COMM, ENT_COMPAT, 'utf-8'); ?>" />
    <tr>
      <td class="td0">VALEUR</td>
      <td><input type="text" name="OCM_Valeur_coordonnee_communication" value="<?php if(isset($_POST['OCM_Valeur_coordonnee_communication'])){ echo remind_text('OCM_Valeur_coordonnee_communication'); }else{ echo htmlentities($oCoordComm->_VALEUR_COORD_COMM, ENT_COMPAT, 'utf-8');} ?>" size="32" maxlength="30" /></td>
    </tr>
    <input type="hidden" name="Identifiant_personne" value="<?php echo htmlentities($oCoordComm->_IDENTIFIANT_PERSONNE, ENT_COMPAT, 'utf-8'); ?>" />
  </table>
    </div>
</div>
<div class="imgright"></div>				
<div class="cleared"></div>

<div class="bt1">
	<a href="../communicationmc/index.php?Identifiant_personne=<?php echo $_GET['Identifiant_personne']; ?>">
    	<span class="btleft"></span>
        <span class="btmiddle">Annuler</span>
        <span class="btright"></span>
    </a>
</div>
<!--div class="bt">
	<a href="modcommunication.php?Identifiant_communication=<?php echo $oCoordComm->_IDENTIFIANT_COMM; ?>&Identifiant_personne=<?php echo $row_rs_mod['Identifiant_personne']; ?>&supp=1">
	<span class="btleft"></span>
    <span class="btmiddle">Supprimer</span>
    <span class="btright"></span>
    </a>
</div-->
<div class="bt">
	<span class="btleft"></span>
    <input type="submit" name="Valider" value="Valider" class="resizeall btmiddle"/>
    <span class="btright"></span>
</div>
    
<div class="cleared"></div>

  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="Identifiant_communication" value="<?php echo $oCoordComm->_IDENTIFIANT_COMM; ?>" />
</form>
 </div>
</body>
</html>
<?php

include_once PATH_INCLUDE.'inc_pied_page.php';
?>